function prespike_summary()
% show pre_spike data, provide a summary.
% % STA analysis of rising phase of second pulse
% including spectral content, slope, variance.
%
% 10/27/02 P. Manis
%

global CONTROL

try
   sf = getmainselection;
   if(sf > 0) 
      pflag = getplotflag;
      QueMessage('prespike summary', 1); % clear the que
      
      
      fn = {CONTROL(sf).filename}; % get the filenames
      [u, sfu] = unique(fn); % find the unique filenames in the selection
      for j = 1:length(u)
         sf2 = find(strcmp(u{j}, fn)); % find all entries that match the selected names
         slope = [];
         var = [];
         fsl = [];
         for i = 1:length(sf2) % for each file, run through the groups
            nsf = sf(sf2(i)); % this pulls a single entry
            %            fprintf('sf: %d   file: %s recbeg: %d\n', nsf, CONTROL(nsf).filename, CONTROL(nsf).recbeg);
            slope(i,:) = CONTROL(nsf).spike.pre_slope;
            var(i,:) = CONTROL(nsf).spike.pre_var;
            fsl(i,:) = CONTROL(nsf).spike.fsl;
         end;
      end;
      hf = findobj('tag', 'prespikesummary');
      if(isempty(hf))
         hf = figure('tag', 'prespikesummary');
      end;
      figure(hf);
      clf;
      symc = {'ko', 'k^', 'ks', 'kd'};
      syme = {'ro', 'r^', 'rs', 'rd'};
      n = length(u);
      for j = 1:length(u)
         subplot(3,n,j);
         sf2 = find(strcmp(u{j}, fn)); % find all entries that match the selected names
         ms = CONTROL(sf(sf2(1))).spike.pre_slope;
         dt = 1:length(ms);
         dt = dt*30
         plot(dt, ms, symc{j}, 'markersize', 3);
         set(gca, 'Xlim', [0 1200], 'fontsize', 7);
      end;
      for j = 1:length(u)
         subplot(3,n,j+n);
         sf2 = find(strcmp(u{j}, fn)); % find all entries that match the selected names
         ms = CONTROL(sf(sf2(1))).spike.pre_var;
         plot(dt, ms, symc{j}, 'markersize', 3);
         hold on
         set(gca, 'Xlim', [0 1200], 'fontsize', 7);
      end;
      
      
   end;
   
catch
   watchoff;
   QueMessage('Error in Forward2 summary routine', 1);
end;
